<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="/js/jquery-3.5.1.min.js"></script>
    <script src="/js/popper.min.js"></script>
    <script src="js/bootstrap.min.js" type="application/javascript"></script>
    <!--    <script src="/secondHand/js/login.js"></script>-->
</head>
<body >



<button onclick="test()">验证码</button>
<img id="myImage" src="" onclick="test()">
</body>
    <script>
        test();
        function test() {
            $.ajax({
                type:"get",
                url:"/captchaImage",
                contentType:"application/json;charset=utf-8",
                success:function (data) {
                    console.log(data);
                    document.getElementById("myImage").src="data:image/png;base64,"+ data.img;
                },
                error:function () {
                    alert("error");
                }

            });
        }
    </script>
</html>